﻿var status = 0;
var choice;
var scrolls = Array(
Array("", 1112447, 0),
Array("", 1112448, 0),
Array("", 1112449, 0),
Array("", 1112450, 0),
Array("", 1112451, 0),
Array("", 1112452, 0),
Array("", 1112453, 0),
Array("", 1112454, 0),
Array("", 1112455, 0),
Array("", 1112456, 0),
Array("", 1112457, 0),
Array("", 1112458, 0),
Array("", 1112459, 0),
Array("", 1112460, 0),
Array("", 1112461, 0),
Array("", 1112462, 0),
Array("", 1112463, 0),
Array("", 1112464, 0),
Array("", 1112465, 0),
Array("", 1112466, 0),
Array("", 1112467, 0),
Array("", 1112468, 0),
Array("", 1112469, 0),
Array("", 1112470, 0),
Array("", 1112471, 0),
Array("", 1112472, 0),
Array("", 1112473, 0),
Array("", 1112474, 0),
Array("", 1112475, 0),
Array("", 1112476, 0),
Array("", 1112477, 0),
Array("", 1112478, 0),
Array("", 1112479, 0),
Array("", 1112480, 0),
Array("", 1112481, 0),
Array("", 1112482, 0),
Array("", 1112483, 0),
Array("", 1112484, 0),
Array("", 1112485, 0),
Array("", 1112486, 0),
Array("", 1112487, 0),
Array("", 1112488, 0),
Array("", 1112489, 0),
Array("", 1112490, 0),
Array("", 1112491, 0),
Array("", 1112492, 0),
Array("", 1112493, 0),
Array("", 1112494, 0),
Array("", 1112495, 0),
Array("", 1112500, 0),
Array("", 1112534, 0),
Array("", 1112535, 0),
Array("", 1112536, 0),
Array("", 1112537, 0),
Array("", 1112538, 0),
Array("", 1112539, 0),
Array("", 1112540, 0),
Array("", 1112541, 0),
Array("", 1112542, 0),
Array("", 1112543, 0),
Array("", 1112544, 0),
Array("", 1112545, 0),
Array("", 1112546, 0),
Array("", 1112547, 0),
Array("", 1112548, 0),
Array("", 1112549, 0),
Array("", 1112550, 0),
Array("", 1112551, 0),
Array("", 1112552, 0),
Array("", 1112553, 0),
Array("", 1112554, 0),
Array("", 1112555, 0),
Array("", 1112556, 0),
Array("", 1112557, 0),
Array("", 1112558, 0),
Array("", 1112559, 0),
Array("", 1112560, 0),
Array("", 1112561, 0),
Array("", 1112562, 0),
Array("", 1112563, 0),
Array("", 1112564, 0),
Array("", 1112565, 0),
Array("", 1112566, 0),
Array("", 1112567, 0),
Array("", 1112568, 0),
Array("", 1112569, 0),
Array("", 1112570, 0),
Array("", 1112571, 0),
Array("", 1112572, 0),
Array("", 1112573, 0),
Array("", 1112574, 0),
Array("", 1112575, 0),
Array("", 1112576, 0),
Array("", 1112577, 0),
Array("", 1112578, 0),
Array("", 1112579, 0),
Array("", 1112580, 0),
Array("", 1112581, 0),
Array("", 1112582, 0),
Array("", 1112583, 0),
Array("", 1112584, 0),
Array("", 1112585, 0),
Array("", 1112586, 0),
Array("", 1112587, 0),
Array("", 1112588, 0),
Array("", 1112589, 0),
Array("", 1112590, 0),
Array("", 1112591, 0),
Array("", 1112592, 0),
Array("", 1112593, 0),
Array("", 1112594, 0),
Array("", 1112595, 0),
Array("", 1112596, 0),
Array("", 1112597, 0),
Array("", 1112598, 0),
Array("", 1112599, 0),
Array("", 1112600, 0),
Array("", 1112601, 0),
Array("", 1112602, 0),
Array("", 1112603, 0),
Array("", 1112604, 0),
Array("", 1112605, 0),
Array("", 1112606, 0),
Array("", 1112607, 0),
Array("", 1112608, 0),
Array("", 1112609, 0),
Array("", 1112610, 0),
Array("", 1112611, 0),
Array("", 1112612, 0),
Array("", 1112613, 0),
Array("", 1112653, 0),
Array("", 1112656, 0),
Array("", 1112657, 0),
Array("", 1112658, 0),
Array("", 1112659, 0),
Array("", 1112661, 0),
Array("", 1112662, 0),
Array("", 1112663, 0),
Array("", 1112664, 0),
Array("", 1112665, 0),
Array("", 1112666, 0),
Array("", 1112667, 0),
Array("", 1112668, 0),
Array("", 1112670, 0),
Array("", 1112671, 0),
Array("", 1112672, 0),
Array("", 1112673, 0),
Array("", 1112675, 0),
Array("", 1112676, 0),
Array("", 1112677, 0),
Array("", 1112678, 0),
Array("", 1112679, 0),
Array("", 1112681, 0),
Array("", 1112682, 0),
Array("", 1112683, 0),
Array("", 1112685, 0),
Array("", 1112686, 0),
Array("", 1112687, 0),
Array("", 1112688, 0),
Array("", 1112689, 0),
Array("", 1112712, 0),
Array("", 1112713, 0),
Array("", 1112714, 0),
Array("", 1112715, 0),
Array("", 1112718, 0),
Array("", 1112719, 0),
Array("", 1112720, 0),
Array("", 1112721, 0),
Array("", 1112723, 0),
Array("", 1112726, 0),
Array("", 1112727, 0),
Array("", 1112735, 0),
Array("", 1112736, 0),
Array("", 1112738, 0),
Array("", 1112739, 0),
Array("", 1112740, 0),
Array("", 1112742, 0),
Array("", 1112743, 0),
Array("", 1112744, 0),
Array("", 1112746, 0),
Array("", 1112747, 0),
Array("", 1112748, 0),
Array("", 1112750, 0),
Array("", 1112751, 0),
Array("", 1112752, 0),
Array("", 1112782, 0),
Array("", 1112783, 0),
Array("", 1112784, 0),
Array("", 1112788, 0),
Array("", 1112797, 0),
Array("", 1112798, 0),
Array("", 1112799, 0),
Array("", 1112804, 0),
Array("", 1112907, 0),
Array("", 1112915, 0),
Array("", 1113000, 0),
Array("", 1113001, 0),
Array("", 1113002, 0),
Array("", 1113005, 0),
Array("", 1113006, 0),
Array("", 1113008, 0),
Array("", 1113009, 0),
Array("", 1113010, 0),
Array("", 1119996, 0),
Array("", 1119997, 0),
Array("", 1119998, 0),
Array("", 1119999, 0)
);

function start() {
    status = -1;
    action(1, 0, 0);
}

function action(mode, type, selection) {
    if (mode == -1) cm.dispose();
    else {
        if (status == 0 && mode == 0) {
            cm.dispose();
            return;
        } else if (status >= 1 && mode == 0) {
            cm.sendOk("好吧，欢迎下次继续光临！.");
            cm.dispose();
            return;
        }
        if (mode == 1) status++;
        else status--;

        if (status == 0) {
            choices = "\r\n兔兔币余额：#r" + cm.getHyPay(1) + "#k个 (#r买后不支持退货哟亲#k)";
            for (var i = 0; i < scrolls.length; i++) {
                choices += "\r\n#L" + i + "##v" + scrolls[i][1] + "##z" + scrolls[i][1] + "#　#d需要#r" + scrolls[i][2] + "#d兔兔币#k#l";
            }
            cm.sendSimpleS("欢迎来到戒指店,你想买我们商店的物品么?请选择吧：." + choices,2);
        } else if (status == 1) {
            cm.sendYesNo("你确定需要购买#v" + scrolls[selection][1] + "##t" + scrolls[selection][1] + "#?");
		choice = selection;
        } else if (status == 2) {
            var money = scrolls[choice][2];
            if (cm.getHyPay(1) < money) {
                cm.sendOk("抱歉，你没足够的兔兔币！");
                cm.dispose();
            } else {
                cm.addHyPay(money);
                cm.gainItem(scrolls[choice][1], 1);
                cm.sendOk("购买成功.");
                cm.dispose();
            }
        }
    }
}